package com.family.pedigree.service.impl;


import cn.hutool.core.util.RandomUtil;
import com.family.common.utils.StringUtils;
import com.family.pedigree.domain.FamilyProcess;
import com.family.pedigree.mapper.FamilyProcessMapper;
import com.family.pedigree.service.IFamilyProcessService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 流程定义表 服务实现类
 * </p>
 *
 * @author forever
 * @since 2024-11-24
 */
@Service
public class FamilyProcessServiceImpl extends ServiceImpl<FamilyProcessMapper, FamilyProcess> implements IFamilyProcessService {

    @Override
    public void add(FamilyProcess process) {
        save(process.setProcessDefId(RandomUtil.randomString(15))
                .setCreateTime(LocalDateTime.now()));
    }

    @Override
    public void edit(FamilyProcess process) {
        updateById(process);
    }

    @Override
    public List<?> getList(FamilyProcess process) {
        return lambdaQuery()
                .like(StringUtils.isNotBlank(process.getProcessName()), FamilyProcess::getProcessName, process.getProcessName())
                .orderByDesc(FamilyProcess::getCreateTime)
                .list();
    }

    @Override
    public void delById(Long processId) {

        removeById(processId);

    }
}
